package com.xyq.fs.index;

import java.io.IOException;
import java.nio.file.Path;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.TextField;
import org.apache.lucene.document.Field.Store;
import com.xyq.fs.base.MyDirectoryS;
import com.xyq.fs.constants.FieldConstant;
import com.xyq.fs.contants.filesuffixes2.PptEnums;

public class IndexPptFiles implements IndexFileInf {

	@Override
	public void indexFile(Path path, String bz) {

		String ps = path.toString().toUpperCase();
		Document doc = null;
		String content = "";
		if (ps.endsWith(PptEnums.PPTX)) {
			doc = getSimDoc(path, PptEnums.PPTX, bz);
		} else if (ps.endsWith(PptEnums.PPT)) {
			doc = getSimDoc(path, PptEnums.PPT, bz);
		}
		try {
			content = getContent(path);
		} catch (Exception e) {
			System.out.println("无法解析" + path);
		} finally {
			TextField tf = new  TextField(FieldConstant.FILE_CONTENT, content, Store.NO);
			doc.add(tf);
			MyDirectoryS.addDocument(doc);
			tf = null;
			doc.clear();
			doc = null;
			content = null;
			ps = null;
			path = null;
			bz = null;
		}
	}

	public static void main(String[] args) throws IOException {

	}
}
